import type { ImageBaseInfo } from '../../../../lib/utils/browser/file'
import type { PlatformTypeValue } from '../../../../types/interfaces'

export interface ImagePreviewBaseConfig {
  selector: string
  listen?: boolean
  imageTitleFetchType?: 'text' | 'attr'
  getImageUrl: ($element: JQuery<HTMLElement>) => string
  getImageTitle?: ($element: JQuery<HTMLElement>) => string
}

export interface ImagePreviewConfig {
  selectors: ImagePreviewBaseConfig[]
  listen?: boolean
}

export type ImagePreviewPlatformConfig = Partial<Record<PlatformTypeValue, Record<string, ImagePreviewConfig>>>

export interface PreviewState {
  element: JQuery<HTMLElement>
  imageUrl: string
  title: string
  path: string
  preload?: boolean
  previewElement: JQuery<HTMLElement> | null
  previewButton: JQuery<HTMLElement> | null
  imageInfo?: ImageBaseInfo
  downloaded?: boolean // 下载状态
  downloadTime?: number // 下载时间
}

export interface CachedImageInfo extends ImageBaseInfo {
  timestamp: number
  lastAccessed: number
}
